#pragma once

#include <gtl/string/str.h>
#include <gtl/ui/skins/pane.h>
#include <gtl/geometry/point.h>
#include <gtl/ui/skins/popuplist.h>

namespace gtl
{

namespace skins
{

class combox
	: public CButton
	, public control<combox, 'cmbx'>
{
	auto_reg_to_the_factory();

public:
	combox();
	virtual ~combox();

public:
	virtual unsigned int initialize(gtl::xml& node, wnd* parent_wnd);

public:
	int GetCount() const;

	int GetCurSel() const;
	int SetCurSel(int nSelect);

	int GetLBText(int nIndex, LPTSTR lpszText) const;	
	void GetLBText(int nIndex, CString& rString) const;
	
	int AddString(LPCTSTR lpszString);
	int DeleteString(UINT nIndex);
	int InsertString(int nIndex, LPCTSTR lpszString);
	
	void ResetContent();

	int FindString(int nStartAfter, LPCTSTR lpszString) const;
	int SelectString(int nStartAfter, LPCTSTR lpszString);

protected:
	void BitBlt(CDC* pDC, CDC& mdc, CRect& rc, CBitmap* pBmp, CPoint ptOffset);

protected:
	DECLARE_MESSAGE_MAP()
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual void PreSubclassWindow();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnKillFocus(CWnd* pNewWnd);

protected:
	bool	 m_popuped;
	bool	 m_pt_in_rect;
	COLORREF m_text_clr;
	bitmap*	 m_normal_img;
	bitmap*  m_hover_img;
	bitmap*  m_down_img;
	bitmap*  m_disable_img;
	gtl::geometry::point m_normal_img_offset;
	gtl::geometry::point m_hover_img_offset;
	gtl::geometry::point m_down_img_offset;
	gtl::geometry::point m_disable_img_offset;

	int m_cur_sel;
	popuplist m_popuplist;
	std::vector<gtl::tstr> m_data;
};

} // end of namespace skins

} // end of namespace gtl